<template>
  <div class="app-container">
    <el-form :model="formData" label-width="120px" label-position="left">
      <el-form-item label="高分数">
        <el-input v-model="formData.high"></el-input>
      </el-form-item>
      <el-form-item label="低分数">
        <el-input v-model="formData.low"></el-input>
      </el-form-item>
    </el-form>
    <div class="submit-box">
      <el-button type="primary" :loading="loading" style="width: 200px;" @click.native.prevent="doSubmit">提交</el-button>
    </div>
  </div>
</template>

<script>
  import {
    create
  } from '@/api/college_level'
  import {
    errorMsg,
    successMsg
  } from '@/utils/my'

  export default {
    data() {
      return {
        loading: false,
        formData: {
          high: '',
          low: ''
        }
      }
    },

    methods: {
      doSubmit() {
        let that = this,
          d = that.formData
        if (d.high.length <= 0) {
          return errorMsg('请输入高分数')
        }
        if (d.low.length <= 0) {
          return errorMsg('请输入低分数')
        }
        that.loading = true
        create(d).then(res => {
          that.loading = false
          if (res.code != 20000) {
            return errorMsg(res.message)
          }
          successMsg(res.message)
          setTimeout(function() {
            that.$router.push({
              path: '/admin/college-level/list'
            })
          }, 500)
        })
      }
    }
  }
</script>

<style>
  .submit-box {
    height: 50px;
    line-height: 50px;
    text-align: center;
    padding-right: 20px;
  }
</style>
